package com.auth.manager.utils;

import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;

/**
 * @version 1.0.0
 * @Date: 2022/4/29 10:27
 * @Author ZhuYouBin
 * @Description 密码工具类
 */
public class PasswordUtil {

    /**
     * 密码校验
     * @param rawPassword 前端密码
     * @param encodePassword 数据库密码
     * @return
     */
    public static boolean matches(String rawPassword, String encodePassword) {
        return new BCryptPasswordEncoder().matches(rawPassword, encodePassword);
    }

    /**
     * 密码加密
     * @param rawPassword 明文密码
     * @return
     */
    public static String encode(String rawPassword) {
        return new BCryptPasswordEncoder().encode(rawPassword);
    }

}
